import { InputQuestion, QuestionBase, SelectQuestion, TableBase, TextTable, TimeQuestion } from '@/components/public-template';
import { Api } from '@/config/api/currentDocumentReport';

class HomeService {
  getQuestions() {
    const questions: QuestionBase<any>[] = [
      new InputQuestion({
        key: 'name',
        label: '文件名称',
        value: null
      }),
      new InputQuestion({
        key: 'code',
        label: '文件编码',
        value: null
      }),
      new SelectQuestion({
        key: 'directoryId',
        label: '文件类别',
        prompt: '请选择',
        value: [],
        type: 'tree',
        state: {
          mode: 'multiple',
          url: Api.currentReportTypeTree,
          protType: 'post',
          nameKey: 'name',
          nameValue: 'id',
          nameChildren: 'children'
        }
      }),
      new SelectQuestion({
        key: 'secretLevel',
        label: '保密等级',
        value: [],
        defaultValue: [],
        type: 'dictionary',
        state: {
          mode: 'multiple',
          filterName: 'SECRET_LEVEL'
        }
      }),
      new SelectQuestion({
        key: 'principalId',
        label: '文件负责人',
        prompt: '请选择',
        value: [],
        state: {
          mode: 'multiple',
          url: Api.subjectListSimple,
          protType: 'post',
          nameKey: 'nickName',
          nameValue: 'id',
          showSearch: true,
          optionFilterProp: 'label'
        }
      }),
      new TimeQuestion({
        key: 'effectTime',
        label: '生效日期',
        value: [],
        state: {
          format: 'YYYY-MM-DD',
          valueFormat: 'YYYY-MM-DD HH:mm:ss',
          keySplit: ['startEffectTime', 'endEffectTime']
        }
      }),
      new InputQuestion({
        key: 'mainContent',
        label: '主要内容',
        value: null
      })
    ];
    return questions;
  }
  getTables() {
    const tables: TableBase<any>[] = [
      new TextTable({
        key: 'num',
        value: '序号',
        type: 'index'
      }),
      new TextTable({
        key: 'name',
        value: '文件名称'
      }),
      new TextTable({
        key: 'code',
        value: '文件编码'
      }),
      new TextTable({
        key: 'version',
        value: '版本号'
      }),
      new TextTable({
        key: 'directoryName',
        value: '文件类别'
      }),
      new TextTable({
        key: 'principalName',
        value: '文件负责人'
      }),
      new TextTable({
        key: 'effectTime',
        value: '生效日期'
      }),
      new TextTable({
        key: 'mainContent',
        value: '主要内容'
      }),
      new TextTable({
        key: 'previewNum',
        value: '预览次数'
      }),
      new TextTable({
        key: 'downloadNum',
        value: '预览次数'
      })
    ];
    return tables;
  }
  getIcons() {
    const icons: TableBase<any>[] = [
      new TextTable({
        key: 'select',
        value: '导出',
        options: [
          {
            key: 'download',
            label: '导出选中',
            state: {
              url: Api.currentReportRecordPage,
              keyName: 'id',
              fileName: '现行文件报表.xlsx'
            }
          },
          {
            key: 'download',
            label: '导出全部',
            state: {
              type: 'all',
              url: Api.currentAllFilePage,
              fileName: '现行文件报表.xlsx'
            }
          }
        ]
      })
    ];
    return icons;
  }
}

export default new HomeService();
